# THIS IS THE OLD MAKEFILE
#
#CC	=/usr/local/cross/bin/i586-elf-gcc
#CFLAGS	=-Werror
#LDFLAGS	=-nostdlib -fno-builtin -nostartfiles -nodefaultlibs
#LD	=/usr/local/cross/bin/i586-elf-ld
#
#all:kernel.img
#
#loader.o:
#	nasm -f elf -o loader.o loader.s
#
#kernel.o:loader.o
#	$(CC) $(CFLAGS) $(LDFLAGS) -o kernel.o -c kernel.c
#
#kernel.bin:kernel.o
#	$(LD) -T linker.ld -o kernel.bin loader.o kernel.o
#
#kernel.img:kernel.bin
#	dd if=/dev/zero of=pad bs=1 count=750
#	cat stage1 stage2 pad kernel.bin > kernel.img
#
#clean:
#	rm -f loader.o kernel.o kernel.bin kernel.img
#
#install:
#	rm -f loader.o kernel.o kernel.bin


# Actual makefile follows

CC	=/usr/local/cross/bin/i586-elf-gcc
CFLAGS	=-Wall -O
LDFLAGS =-fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c
LD	=/usr/local/cross/bin/i586-elf-ld

all:main.img

start.o:
	nasm -f elf -o start.o start.asm

main.o:start.o
	$(CC) $(CFLAGS) $(LDFLAGS) -o initidt.o initidt.c
	$(CC) $(CFLAGS) $(LDFLAGS) -o init8259.o init8259.c
	$(CC) $(CFLAGS) $(LDFLAGS) -o kb.o kb.c
	$(CC) $(CFLAGS) $(LDFLAGS) -o screen.o screen.c
	$(CC) $(CFLAGS) $(LDFLAGS) -o main.o main.c

main.bin:main.o
	$(LD) -T link.ld -o main.bin start.o main.o screen.o kb.o initidt.o init8259.o

main.img:main.bin
	dd if=/dev/zero of=pad bs=1 count=750
	cat stage1 stage2 pad main.bin > main.img

clean:
	rm -f start.o init-idt.o init8259.o kb.o screen.o main.o main.bin main.img

install:
	rm -f start.o init-idt.o init8259.o kb.o screen.o main.o main.bin main.img
